package com.lzqysoft.sfyy;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;

import android.app.Activity;
import android.app.LoaderManager.LoaderCallbacks;

import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;

import android.os.Build;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.archermind.policesdk.CrashHandler;
import com.lzqysoft.sfyy.request.PoliceServiceInterface;
import com.lzqysoft.sfyy.request.PoliceServices;
import com.lzqysoft.sfyy.request.PoliceServicesTest;

import java.util.ArrayList;
import java.util.List;

import static android.Manifest.permission.READ_CONTACTS;

/**
 * A login screen that offers login via email/password.
 */
public class LoginActivity extends Activity  {

    /**
     * Id to identity READ_CONTACTS permission request.
     */
    private static final int REQUEST_READ_CONTACTS = 0;



    // UI references.
    private AutoCompleteTextView mEmailView;
    private EditText mPasswordView;
    private View mProgressView;
    private View mLoginFormView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        // Set up the login form.
//        initCrashHandler();
        initPage();
        initData();
    }

    private void initPage() {
        Button btn = (Button) findViewById(R.id.login_btn);
        btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                startActivity(intent);
            }
        });
    }

    /**
     * 第三方APP开发商开发的应用必须使用我们平台提供的SDK Crash异常获取接口
     * 如果不使用将不能通过应用测试，不予发布。
     */
    private void initCrashHandler() {
        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(getApplicationContext());
    }

    /**
     * 初始化用户信息
     */
    private void initData() {
        PoliceServiceInterface ps = new PoliceServicesTest(this);
        TextView dept_value = (TextView)findViewById(R.id.dept_value);
        dept_value.setText(ps.getDeptName());
        TextView name_value = (TextView)findViewById(R.id.name_value);
        name_value.setText(ps.getPoliceName());
        TextView no_value = (TextView)findViewById(R.id.no_value);
        no_value.setText(ps.getUserAccount());
    }

}

